import 'package:ficonsax/ficonsax.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';

import '../design_specifications.dart';


///自定义刷新头部

class RefreshHeader extends StatelessWidget {
  const RefreshHeader({super.key, this.status});
  final RefreshStatus? status;
  @override
  Widget build(BuildContext context) {
    switch (status) {
      case RefreshStatus.refreshing:
        return RefreshItem(SizedBox(
            width: 16.w,
            height: 16.w,
            child: CircularProgressIndicator(
              strokeWidth: 1.5.w, color: textColor,)), "刷新中");
      case RefreshStatus.completed:
        return RefreshItem(Icon(IconsaxOutline.tick_square, size: 20.w,color: textColor,), "已更新");
      case RefreshStatus.idle:
        return RefreshItem(Icon(IconsaxOutline.arrow_square_down, size: 20.w,color: textColor), "下拉刷新");
      case RefreshStatus.canRefresh:
        return RefreshItem(Icon(IconsaxOutline.arrow_square_up, size: 20.w,color: textColor), "松开刷新");
      default:
        return Container();
    }
  }
}

class RefreshItem extends StatelessWidget {
  const RefreshItem(this.icon,this.text,{super.key});
  final Widget icon;
  final String text;
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 24.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          icon,
          SizedBox(width: 8.w,),
          Text(
            text, style: TextStyle(fontSize: 14.sp, fontFamily: harmony),)
        ],
      ),
    );
  }
}

